package com.lh.blogConsumer.service.Impl;

import com.lh.blogCommon.util.PageUtils;
import com.lh.blogCommon.util.Query;
import com.lh.blogConsumer.entity.PersonalCenterEntity;
import com.lh.blogConsumer.entity.ProjectEntity;
import com.lh.blogConsumer.mapper.ProjectMapper;
import com.lh.blogConsumer.service.ProjectService;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.StringUtils;


@Service("projectService")
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, ProjectEntity> implements ProjectService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        QueryWrapper<ProjectEntity> queryWrapper = new QueryWrapper<>();

        String key = (String) params.get("key");
        System.out.println(params);
        if(!StringUtils.isEmpty(key)){
            queryWrapper.eq("project_id",key).or()
                    .eq("project_name",key).or()
                    .eq("technical_point", key).or()
                    .eq("start_time",key).or()
                    .eq("end_time",key);

        }
        queryWrapper.orderByDesc("project_id");

        IPage<ProjectEntity> page = this.page(
                new Query<ProjectEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}